<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" href="../../../component/layui/css/layui.css" media="all">
  <title>Title</title>
  <script src="../../../component/jquery3.6.0.js"></script>
  <style>
    .bottom {
      position: relative;
      left: 25%;
    }
  </style>
</head>
<body>
<form class="layui-form" id="layui-form-id" action="" lay-filter="deliver_edit_form">
  <div class="layui-form-item">
    <label class="layui-form-label"><strong>机会编码</strong></label>
    <div class="layui-input-inline">
      <input id="chance_code" type="text" name="chance_code" lay-verify="title" autocomplete="off" placeholder="请输入计划编码" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label"><strong>机会名称</strong></label>
    <div class="layui-input-inline">
      <input id="chance_name" type="text" name="chance_name" placeholder="请输入姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label"><strong>机会类型</strong></label>
    <div class="layui-input-inline">
      <input id="chance_typename" type="text" name="chance_typename" lay-verify="title" autocomplete="off" placeholder="请输入月份" class="layui-input">
    </div>
  </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label"><strong>机会内容</strong></label>
    <div class="layui-input-inline">
      <textarea id="cm_content"  name="cm_content" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label"><strong>备注信息</strong></label>
    <div class="layui-input-inline">
      <textarea id="des"  name="des" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="bottom">
    <div class="button-container">
      <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="user-save">
        <i class="layui-icon layui-icon-ok"></i>
        提交
      </button>
      <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
        <i class="layui-icon layui-icon-refresh"></i>
        重置
      </button>
    </div>
  </div>
</form>

<script type="text/javascript" src="../../../component/layui/layui.js"></script>

<script>
  layui.use(['form'], function(){
    var form = layui.form;

    form.on('submit(user-save)', function(data){

      //获取隐藏域中的图片
      //data.field.village_Img=$(".image")[0].value;
      console.log(data.field);
      $.ajax({
        url:'http://localhost:8181/Manager_war/CmServlet/add',
        data:data.field,
        dataType:'json',
        // contentType:'application/json',form text  请求的格式 给后端是以json格式进行传输
        type:'post',
        success:function(result){
          if(result.code==0){
            layer.msg(result.msg,{icon:1,time:1000},function(){
              parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
              window.parent.location.reload(true);

            });
          }else{
            layer.msg(result.msg,{icon:2,time:1000});
          }
        }
      })
      return false;
    });


  });


</script>

</body>
</html>